﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/26/2009
 * Time: 10:28 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using NHibernate;
using System.Collections.Generic;
using System.Data;
using Miming.Model.Dao.Interface;

namespace Miming.Model.Dao.NHibernate
{
	/// <summary>
	/// Description of NHibernateShippingMethodDao.
	/// </summary>
	public class NHibernateShippingMethodDao : IShippingMethodDao
	{
		public NHibernateShippingMethodDao()
		{
		}
		
		public void SaveOrUpdate(ShippingMethod method)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.SaveOrUpdate(method);
			session.Flush();
		}
		
		public void Delete(ShippingMethod method)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.Delete(method);
			session.Flush();
		}
		
		public ShippingMethod ReadByPk(int id)
		{
			return NHibernateHelper.OpenSession().Load<ShippingMethod>(id);
		}
		
		public IList<ShippingMethod> FindAll()
		{
			return NHibernateHelper.OpenSession().CreateCriteria(typeof(ShippingMethod)).List<ShippingMethod>();
		}
	}
}
